17.5 Task Weight and Context Switching Mechanism Configuration
The function set_load_weight() sets the scheduling weight for the initial task, which updates the load field inside the sched_entity structure embedded within struct task_struct.
mmgrab() increments the object reference counter belonging to the global kernel memory descriptor init_mm. This mechanism guarantees that the memory translation context of the kernel remains resident and immune to deallocation even when no active user-space processes are running.
When the operating system enters an idle state, the kernel avoids executing costly Translation Lookaside Buffer (TLB) flush operations and bypasses full context switching blocks. Instead, it borrows the page table hierarchy of the previously active process to minimize architectural context switching overhead. This optimization is designated as the Lazy TLB mechanism. The function enter_lazy_tlb() signals to the underlying processor that the execution context has dropped into the kernel space, which safely bypasses user-space page table toggling paths.